<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var rep = [
        "零",
        "一",
        "二",
        "三",
        "四",
        "五",
        "六",
        "七",
        "八",
        "九",
        "十",
      ];
      function getMydate() {
        var time = new Date();
        var res =
          years(time.getFullYear()) +
          "年" +
          getNumber(time.getMonth() + 1) +
          "月" +
          getNumber(time.getDate()) +
          "日" +
          getNumber(time.getHours()) +
          "时" +
          getNumber(time.getMinutes()) +
          "分" +
          getNumber(time.getSeconds()) +
          "秒";

        document.body.innerHTML = res;
      }

      function years(year) {
        var arr = new Array(4);
        arr[0] = parseInt(year / 1000);
        arr[1] = parseInt((year % 1000) / 100);
        arr[2] = parseInt((year % 100) / 10);
        arr[3] = year % 10;
        var res = {};
        for (var i = 0; i < arr.length; i++) {
          res += getNumber(arr[i]);
        }
        return arr.join("");
      }
      function getNumber(t) {
        if (t <= 10) return rep[t];
        if (t > 10 && t < 20) {
          var str = t + "";
          console.log(str);
          str[0] = rep[str[0]];
          str[1] = rep[str[1]];
          return str;
        }
        if (t >= 20 && t <= 59) {
          var str = t + "";
          str[0] = rep[str[0]] + "十";
          str[1] = rep[str[1]];
          return str;
        }
      }
    </script>
  </body>
</html>
